<template>
	<el-dialog v-model="visible" title="日志列表" :close-on-click-modal="false" :close-on-press-escape="false"
		:fullscreen="true">
		<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
			<el-form-item>
				<el-input v-model="dataForm.jobId" size="small" placeholder="任务ID" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<el-button size="small" @click="getDataList()">查询</el-button>
			</el-form-item>
		</el-form>
		<el-table v-loading="dataListLoading" :data="dataList" border @sort-change="dataListSortChangeHandle"
			height="460" style="width: 100%;">
			<el-table-column prop="jobId" label="任务ID" header-align="center" align="center"></el-table-column>
			<el-table-column prop="beanName" label="bean名称" header-align="center" align="center"></el-table-column>
			<el-table-column prop="params" label="参数" header-align="center" align="center"></el-table-column>
			<el-table-column prop="status" label="状态" header-align="center" align="center">
				<template #default="scope">
					<el-tag v-if="scope.row.status === 1" size="small">成功</el-tag>
					<el-tag v-else type="danger" size="small" @click.native="showErrorInfo(scope.row.id)"
						style="cursor: pointer;">失败</el-tag>
				</template>
			</el-table-column>
			<el-table-column prop="times" label="耗时(单位: 毫秒)" header-align="center" align="center"></el-table-column>
			<el-table-column prop="createDate" label="执行时间" header-align="center" align="center" width="180">
			</el-table-column>
		</el-table>
		<el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
			layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
			@current-change="pageCurrentChangeHandle">
		</el-pagination>
	</el-dialog>

</template>

<script>
	import {
		ref,
		reactive,
		onMounted,
		nextTick,
		computed
	} from 'vue';
	import DataList from "@/utils/DataList";
	import {
		ElMessage,
		ElMessageBox
	} from 'element-plus'


	import {
		getScheduleLogById
	} from "@/network/lswms/job/ScheduleLog.js"
	export default {
		name: "scheduleLog",

		setup() {
			const {
				dataForm,
				mixinViewModuleOptions,
				getDataList,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate
			} = DataList();

			onMounted(() => {
				mixinViewModuleOptions.value.getDataListIsPage = true;
				mixinViewModuleOptions.value.getDataListURL = '/sys/scheduleLog/page';
				// mixinViewModuleOptions.value.deleteURL = '/sys/schedule';
				// mixinViewModuleOptions.value.exportURL = '/lswms/orders/export';
				mixinViewModuleOptions.value.deleteIsBatchKey = 'id';
				mixinViewModuleOptions.value.deleteIsBatch = true
				if (mixinViewModuleOptions.value.activatedIsNeed) {
					getDataList();
				}
				// ordersStatusFn();
				// orderypeFn();
			})

			const visible = ref(false)
			const init = () => {
				visible.value = true;
				getDataList();
			}
			const showErrorInfo = (id) => {
				getScheduleLogById(id).then(function(res) {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					// self.$alert(res.data.data.error, vm.$t('logError.errorInfo'), {
					//   customClass: 'mod-job__schedule-view-info'
					// });
				}).catch(function() {});
			}



			return {
				dataForm,
				mixinViewModuleOptions,
				getDataList,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate,

				visible,
				init,
				showErrorInfo
			}
		},
		methods: {
			//hasPermission

			reString: function(val) {
				let n = Number(val)
				if (!isNaN(n)) {
					return n
				} else {
					return val
				}
			}
		},
	}
</script>
<style>
</style>
